import request from "@/utils/request";
import qs from "qs";

export function login(data) {
  let postData = qs.stringify({
    grant_type: "password",
    username: data.username,
    password: data.password,
    scope: "all",
    client_id: "monomer",
    client_secret: "monomer-secret"
  });
  return request({
    url: "/api/oauth/token",
    method: "post",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    data: postData
  });
}

export function getInfo() {
  return request({
    url: "/api/user/current",
    method: "get"
  });
}

export function logout() {
  return request({
    url: "/vue-element-admin/user/logout",
    method: "post"
  });
}
